package lsl.leetCode.test1222;

import lsl.leetCode.TreeNode;

/**
 * description:
 *
 * @author: liushengli
 * data: 2022/12/22
 */
public class test101 {
    public boolean isSymmetric(TreeNode root) {
        return check(root, root);
    }

    public boolean check(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        } else if (p == null && q != null) {
            return false;
        } else if (p != null && q == null) {
            return false;
        } else {
            return p.val == q.val && check(p.left, q.right) && check(p.right, q.left);
        }
    }
}
